package com.itheima.service;

import com.itheima.dao.StuDao;
import com.itheima.dao.StuDaoImpl;
import com.itheima.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: Bytezero_zhengLei
 * @Date: 2024/6/24 21:16
 * @Project_Name:
 * @Email: 420498246@qq.com
 * @Description:
 * @TODO:
 */

//操作层
@Service
@Primary
public class StuService implements ServiceImpl {
    @Autowired
    StuDaoImpl stuDao;

    public List<Student> getStuServiceList() {
        List<Student> studentList = stuDao.getStuData();
        studentList.stream().forEach(student -> {
            if ("1".equals(student.getGender())) {
                student.setGender("男");
            } else if ("2".equals(student.getGender())) {
                student.setGender("女");
            }

            Integer score = student.getScore();
            if (score >= 85) {
                student.setLevel("优秀");
            } else if (score >= 60) {
                student.setLevel("及格");
            } else {
                student.setLevel("不及格");
            }
        });
        return studentList;
    }
}